package com.aaa.controller;

import com.aaa.entity.Result;
import com.aaa.entity.Users;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (Users)表控制层
 *
 * @author makejava
 * @since 2022-11-01 21:34:28
 */
@Controller
public class UserController {
    @GetMapping("/info")
    @ResponseBody
    public Authentication info(){
        return SecurityContextHolder.getContext().getAuthentication();
    }

    @PostMapping("/success")
    public String success(){
        return "success";
    }

    @GetMapping("/user/query")
    @ResponseBody
    @PreAuthorize(value = "hasAnyAuthority('/user/query')")
    public Result query(){
        return new Result(200,"您拥有查询方法",null);
    }

    @GetMapping("/user/delete")
    @ResponseBody
    @PreAuthorize(value = "hasAnyAuthority('/user/delete')")
    public Result delete(){
        return new Result(200,"您拥有删除方法",null);
    }

    @GetMapping("/user/insert")
    @ResponseBody
    @PreAuthorize(value = "hasAnyAuthority('/user/insert')")
    public Result insert(){
        return new Result(200,"您拥有删除方法",null);
    }

    @GetMapping("/user/export")
    @ResponseBody
    @PreAuthorize(value = "hasAnyAuthority('/user/export')")
    public Result export(){
        return new Result(200,"您拥有导出方法",null);
    }

    @GetMapping("/user/update")
    @ResponseBody
    @PreAuthorize(value = "hasAnyAuthority('/user/update')")
    public Result update(){
        return new Result(200,"您拥有更新方法",null);
    }
    ///**
    // * 分页查询
    // *
    // * @param user 筛选条件
    // * @param pageRequest      分页对象
    // * @return 查询结果
    // */
    //@GetMapping
    //public ResponseEntity<Page<Users>> queryByPage(Users user, PageRequest pageRequest) {
    //    return ResponseEntity.ok(this.userService.queryByPage(user, pageRequest));
    //}
    //
    ///**
    // * 通过主键查询单条数据
    // *
    // * @param id 主键
    // * @return 单条数据
    // */
    //@GetMapping("{id}")
    //public ResponseEntity<Users> queryById(@PathVariable("id") Integer id) {
    //    return ResponseEntity.ok(this.userService.queryById(id));
    //}
    //
    ///**
    // * 新增数据
    // *
    // * @param user 实体
    // * @return 新增结果
    // */
    //@PostMapping
    //public ResponseEntity<Users> add(Users user) {
    //    return ResponseEntity.ok(this.userService.insert(user));
    //}
    //
    ///**
    // * 编辑数据
    // *
    // * @param user 实体
    // * @return 编辑结果
    // */
    //@PutMapping
    //public ResponseEntity<Users> edit(Users user) {
    //    return ResponseEntity.ok(this.userService.update(user));
    //}
    //
    ///**
    // * 删除数据
    // *
    // * @param id 主键
    // * @return 删除是否成功
    // */
    //@DeleteMapping
    //public ResponseEntity<Boolean> deleteById(Integer id) {
    //    return ResponseEntity.ok(this.userService.deleteById(id));
    //}

}

